<?php  

class TestCase{
  
  protected $_tests;
  protected $_failedTests;
  
  public function __construct(){
    $this->_tests = new SplObjectStorage();
    $this->_failedTests = new SplObjectStorage();
  }
  
  public function addTest(Test $test){
   if(!$this->_tests->contains($test)){
     $this->_tests->attach($test);
   }
  }
  
  public function run(){
    $this->_tests->rewind();
    while($this->_tests->valid()){
      
      $this->runTest($this->_tests->current());
      
      $this->_tests->next();
    }
  }
  
  public function runTest(Test $test){
    try {
      $test->test();
    } catch (TestFailException $e) {
      $this->_failedTests->attach($test);
    }
  }
  
  
}

?>